<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--css样式引入-->
<head th:replace="admin/common::head-fragment">
</head>

<body>
<!--左边工具栏-->
<nav th:replace="admin/common::navbar-fragment(active='blog.html')"></nav>

<div class="page">

    <!--顶部导航栏-->
    <header th:replace="admin/common::topbar-fragment"></header>

    <!-- Breadcrumb-->
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
            </div><!-- /.container-fluid -->
        </div>
        <!-- Main content -->
        <div class="content">
            <div class="container-fluid">
                <div class="card card-primary card-outline">
                    <div class="card-header">
                        <h3 class="card-title">博客管理</h3>
                    </div> <!-- /.card-body -->
                    <div class="card-body">
                        <div class="grid-btn">
                            <button class="btn btn-success" onclick="addBlog()"><i
                                    class="fa fa-plus"></i>&nbsp;新增
                            </button>
                            <button class="btn btn-info" onclick="updateBlog()"><i
                                    class="fa fa-edit"></i>&nbsp;修改
                            </button>
                            <button class="btn btn-danger" onclick="deleteBlog()"><i
                                    class="fa fa-trash-o"></i>&nbsp;删除
                            </button>&nbsp;&nbsp;
                            &ensp;
                            <input type="text" placeholder="关键字(标题/分类)" id="keyword" class="col-2" align="right">&nbsp;
                            <button class="btn btn-info" onclick="search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索
                            </button>
                        </div>
                        <br/>
                        <div class="table-responsive">
                            <table class="table table-striped table-hover" style="table-layout:fixed;" >
                                <thead>
                                <tr>
                                    <th><input type="checkbox" id="checkController"/></th>
                                    <th>标题</th>
                                    <th>预览图</th>
                                    <th>浏览量</th>
                                    <th>状态</th>
                                    <th>博客分类</th>
                                    <th>创建时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="blog:${allBlog}">
                                    <th scope="row"><input type="checkbox" name="checkOption" /></th>
                                    <td th:text="${blog.getBlogId()}" name="id" style="display:none;"></td>
                                    <td th:text="${blog.getBlogTitle()}" name="title" style="word-wrap:break-word;"></td>
                                    <td name="img">
                                        <img th:src="@{${blog.getBlogCoverImage()}}" height="80" width="140" alt="coverImage"/>
                                    </td>
                                    <td th:text="${blog.getBlogViews()}" name="views" valign="middle"></td>
                                    <td th:switch="${blog.getBlogStatus()}" name="status">
                                        <button th:case="1" type="button" class="btn btn-block btn-success btn-sm" style="width: 50%;">发布</button>
                                        <button th:case="0" type="button" class="btn btn-block btn-secondary btn-sm" style="width: 50%;">草稿</button>
                                    </td>
                                    <td th:text="${blog.getBlogCategoryId()}" name="category-id" style="display:none;"></td>
                                    <td th:text="${blog.getBlogCategoryName()}" name="category-name" style="word-wrap:break-word;"></td>
                                    <td th:text="${blog.getCreateTime()}" name="createTime"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div><!-- /.card-body -->
                </div>
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content -->
    </div>
    <!--底部-->
    <footer th:replace="admin/common::footer-fragment"></footer>

</div>
<!--javascript-->
<div th:replace="admin/common::JavaScript-fragment"></div>

<!--引入自写的blog.js-->
<script th:src="@{/admin/js/blog.js}"></script>
<!-- image-picker -->
<script th:src="@{/vendor/image-picker/jquery.masonry.min.js}"></script>
<script th:src="@{/vendor/image-picker/image-picker.min.js}"></script>

</body>
</html>